/*
 *  Copyright (c) GBA-NCTI-ISDC. 2022-2024.
 *
 *  openGauss DataKit is licensed under Mulan PSL v2.
 *  You can use this software according to the terms and conditions of the Mulan PSL v2.
 *  You may obtain a copy of Mulan PSL v2 at:
 *
 *  http://license.coscl.org.cn/MulanPSL2
 *
 *  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 *  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 *  MERCHANTABILITY OR FITFOR A PARTICULAR PURPOSE.
 *  See the Mulan PSL v2 for more details.
 *  -------------------------------------------------------------------------
 *
 *  WebsocketServerTest.java
 *
 *  IDENTIFICATION
 *  plugins/data-studio/src/test/java/com/nctigba/datastudio/base/WebsocketServerTest.java
 *
 *  -------------------------------------------------------------------------
 */

package com.nctigba.datastudio.base;

import com.nctigba.datastudio.model.entity.OperateStatusDO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.ApplicationContext;

import javax.websocket.Session;
import java.sql.Connection;
import java.sql.Statement;

/**
 * WebsocketServerTest
 *
 * @since 2023-07-14
 */
@Slf4j
@RunWith(MockitoJUnitRunner.class)
public class WebsocketServerTest {
    @InjectMocks
    private WebSocketServer webSocketServer;

    @Mock
    private Connection connection;

    @Mock
    private Statement statement;

    @Mock
    private Session session;

    @Mock
    private OperateStatusDO operateStatusDO;

    @Mock
    private ApplicationContext applicationContext;

    @Test
    public void testOnClose() {
        webSocketServer.onClose("webds-plugin", "postgres");
    }

    @Test
    public void testGetStatement() {
        webSocketServer.getStatement("webds-plugin");
    }

    @Test
    public void testSetStatement() {
        webSocketServer.setStatement("webds-plugin", statement);
    }

    @Test
    public void testSetConnection() {
        webSocketServer.setConnection("webds-plugin", connection);
    }

    @Test
    public void testGetOperateStatus() {
        webSocketServer.getOperateStatus("webds-plugin");
    }

    @Test
    public void testSetOperateStatus() {
        webSocketServer.setOperateStatus("webds-plugin", operateStatusDO);
    }

    @Test
    public void testGetLanguage() {
        webSocketServer.getLanguage();
    }

    @Test
    public void testSetLanguage() {
        webSocketServer.setLanguage("zh_CN");
    }
}
